import axios from 'axios';
import {Message} from "element-ui";
import store from "@/store";

axios.interceptors.response.use((response) => {
    console.log(response, "接口返回值");
    if (response.data.code !== 1000) {
        Message.error(response.data.message);
        throw new Error(response.data.message);
    }
    return response.data.data
})

axios.interceptors.request.use((config)=>{
    config.headers["Authorization"] = store.state.token
    return config
})

export default axios
